# -*- coding: utf-8 -*-
# @Author : HaleShi
# @Time : 2023-06-16
# @File : 1_hook.py


import frida
import sys

rdev = frida.get_remote_device()
# Application(identifier="tv.danmaku.bili", name="", pid=20650, parameters={})
session = rdev.attach("Momo")

scr = """
Java.perform(function () {
    var t = Java.use("com.immomo.momo.t");
    t.a.overload('com.immomo.momo.t$a').implementation = function(aVar){
        console.log("——————————————————————请求来了——————————————————————");
        console.log("——————————————————————这是aVar",aVar);
        
        var res = this.a(aVar)
        console.log("——————————————————————这是返回值",res);
        console.log(Java.use("android.util.Log").getStackTraceString(Java.use("java.lang.Throwable").$new()));
        return res
    };
});
"""

script = session.create_script(scr)


def on_message(message, data):
    print(message, data)


script.on("message", on_message)

script.load()
sys.stdin.read()
